<template>
  <el-dialog title="嵌套表格的弹框" :visible.sync="visible" width="30%">
    <el-form :model="form" ref="form">
      <el-form-item label="提交信息" :label-width="formLabelWidth" prop="message" :rules="rules">
        <el-input v-model="form.message" auto-complete="off" placeholder="请输入信息"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="confirm('form')">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
  import ApiClient from '@/utils/ApiClient'

  export default {
    name:'AppDialogBase',
    props: {
      show: {type: Boolean, default: false},
    },
    data() {
      return {
        formLabelWidth: '120px',
        form: {
          message: '',
        },
        rules: {required: true, message: '不能为空', trigger: 'blur'},
      }
    },
    methods: {
      close() {
        this.$emit('update:show', false)
      },
      //操作
      confirm(form) {
        this.$refs[form].validate((valid) => {
          if (valid) {
            this.close()
          } else {
            return false;
          }
        });
      }
    },
    computed: {
      visible: {
        get: function () {
          return this.show == false ? false : true
        },
        set: function () {
          this.$emit('update:show', false)
        }
      }
    },
    mounted() {
    }
  }
</script>
<style scoped>
  .el-dialog__header{
    text-align: center;
  }
</style>
